#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#include "bounded_vector.h"

string readLetters(string filename)
{
	ifstream in(filename);
	char c;
	string result = "";
	while (in >> c)
	{
		if (c >= 'a' && c <= 'z')
		{
			result += c;
		}
	}
	return result;
}

void main42()
{
	bounded_vector bv1('a', 'z');
	bounded_vector bv2('a', 'z');
	string char1 = readLetters("char1.txt");
	string char2 = readLetters("char2.txt");

	for (int i = 0; i < char1.size(); i++)
	{
		bv1[char1[i]] += 1;
	}

	for (int i = 0; i < char2.size(); i++)
	{
		bv2[char2[i]] += 1;
	}

	char c = 'a';
	while (c <= 'z')
	{
		cout << c << ": " << bv1[c] - bv2[c] << " , " << bv1[c] << " , " << bv2[c] << endl;
		c++;
	}
}

void main43()
{
	bounded_vector bv1('a', 'z');
	bounded_vector bv2('a', 'z');
	string char1 = readLetters("char1.txt");
	string char2 = readLetters("char2.txt");

	for (int i = 0; i < char1.size(); i++)
	{
		bv1[char1[i]] += 1;
	}

	for (int i = 0; i < char2.size(); i++)
	{
		bv2[char2[i]] += 1;
	}

	char c = 'a';
	int totprombv1 = 0;
	int totprombv2 = 0;
	while (c <= 'z')
	{
		int bv1prom = 1000 * bv1[c] / bv1.sum();
		totprombv1 += bv1prom;
		int bv2prom = 1000 * bv2[c] / bv2.sum();
		totprombv2 += bv2prom;
		cout << c << ": " << bv1prom - bv2prom << " , " << bv1prom << " , " << bv2prom << endl;
		c++;
	}
	cout << "tot : " << totprombv1 << " , " << totprombv2 << endl;
}

int main()
{
	//main42();
	main43();

	system("pause");
	return 0;
}